package com.oo.packaging_2.commodity;

/**
 * Commodity--${description}
 *
 * @author: Jovi
 * @createTime: 2017-04-19 15:31
 **/
public class Commodity {

    private int id;

    private String name;

    private CommodityType commodityType;

    private int count;

    private int price;

    public Commodity(int id, String name, CommodityType commodityType, int count, int price) {
        this.id = id;
        this.name = name;
        this.commodityType = commodityType;
        this.setCount(count);
        this.setPrice(price);
    }

    public Commodity() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public CommodityType getCommodityType() {
        return commodityType;
    }

    public void setCommodityType(CommodityType commodityType) {
        this.commodityType = commodityType;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        if (count < 0) {
            System.out.println("数量不能小于0");
        }else
        this.count = count;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        if (price < 0) {
            System.out.println("价格不能小于0");
        }else
        this.price = price;
    }

    //盘点的方法，描述商品信息。内容包括商品名称，商品数量，商品价格，现有商品总价以及所属类别信息
    public void check() {
        String msg = "商品名称：" + this.name + "\n所属类别："
                + this.commodityType.getTypeName() + "\n商品售价：" + this.price + "\n库存数量："
                + this.count + "\n商品总价：" + this.price * this.count;
        System.out.println(msg);
    }
}
